using UnityEngine;

namespace MaterialUI
{
	public static class MonoBehaviourExtension
	{
		public static T GetAddComponent<T>(this MonoBehaviour monoBehaviour) where T : Component
		{
			if ((Object)monoBehaviour.GetComponent<T>() != (Object)null)
			{
				return monoBehaviour.GetComponent<T>();
			}
			return monoBehaviour.gameObject.AddComponent<T>();
		}

		public static T GetChildByName<T>(this MonoBehaviour monoBehaviour, string name) where T : Component
		{
			return monoBehaviour.gameObject.GetChildByName<T>(name);
		}
	}
}
